var $ = getApp(), methods = require("../methods.js");
Page(Object.assign({}, methods, {
	data: {
		title:'发表评论',
		type:0,
		id:'',
		hfid:'',
		faceshow:false,
		content:'',
	},
	_onLoad:function(){
		var that = this
		that.setData({type:that.options.type,id:that.options.id,hfid:that.options.hfid});
		if(that.options.hfid){
			that.setData({title:'回复评论'})
		}
	},
	showface:function(){
		this.setData({faceshow:!this.data.faceshow})	
	},
	selectface:function(e){
		var face = e.currentTarget.dataset.face;
		var content = this.data.content + face;
		this.setData({faceshow:false,content:content})
	},
	setcontent:function(e){
		this.setData({content:e.detail.value})	
	},
	subpinglun:function(){
		var that = this;
		var id = that.data.id;
		var type = that.data.type;
		var hfid = that.data.hfid;
		var content = that.data.content;
		if(content==''){
			$.error('请输入评论内容');return;
		}
		$.loading('提交中');
		$.post("article/subpinglun",{id:id,type:type,hfid:hfid,content:content},function(res){
			$.loading(false);
			if(res.status==1){
				$.success(res.msg);
				setTimeout(function(){
					$.goback(true);
				},1000);
			}else{
				$.error(res.msg);
			}
		})
	}
}))